﻿using MongoDB.Bson;
using MongoDB.Driver;
using Project.Core.Common;
using Project.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Project.Core.IRepository.Base
{
    /// <summary>
    /// 仓储 泛型 基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseRepository<T> where T : BaseModel, new()
    {
        Task<int> Insert(T Entity);
        Task<bool> Delete(T Entity);
        Task<bool> Delete(int Id);
        Task<List<T>> Query(Expression<Func<T, bool>> expression);
        Task<PageDataList<T>> QueryByCondition(Expression<Func<T, bool>> expression, bool IsPage, int PageIndex, int PageSize, Expression<Func<T, object>> orderExpression, bool isAsc);
        Task<bool> Update(T Entity);
        Task<T> Find(Expression<Func<T, bool>> expression);

        #region mongoDB
        /// <summary>
        /// 同步插入数据
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        // bool InsertOneData(T Entity);
        /// <summary>
        /// 异步插入
        /// </summary>
        /// <param name="Entity">实体</param>
        /// <returns></returns>
        // Task<bool> InsertAsyncOneData(T Entity);
        /// <summary>
        /// 同步插入多条数据
        /// </summary>
        /// <param name="Entitys">多个实体</param>
        /// <returns></returns>
        // bool InsertManyData(IEnumerable<T> Entitys);
        /// <summary>
        /// 异步插入多条数据
        /// </summary>
        /// <param name="documents"></param>
        /// <returns></returns>
        // Task<bool> InsertAsyncManyData(IEnumerable<T> Entitys);

        /// <summary>
        /// 同步删除
        /// </summary>
        /// <param name="Entity">实体</param>
        /// <returns></returns>
        // bool Delete(T Entity);
        /// <summary>
        /// 异步删除
        /// </summary>
        /// <param name="Entity">实体</param>
        /// <returns></returns>
        // Task<bool> DeleteAsync(T Entity);
        /// <summary>
        /// 异步删除
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns></returns>
        // Task<bool> DeleteByIdAsync(int id);
        /// <summary>
        /// 同步删除
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns></returns>
        // bool DeleteById(int id);
        /// <summary>
        /// 异步多个删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        // Task<bool> DeleteByIds(int[] ids);
        /// <summary>
        /// 同步多个删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        // bool DeleteByIdsAsync(int[] ids);

        /// <summary>
        /// 同步更新
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        // bool Update(Expression<Func<T, bool>> filter, UpdateDefinition<T> update);

        /// <summary>
        /// 异步更新
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        // Task<bool> UpdateAsync(Expression<Func<T, bool>> filter, UpdateDefinition<T> update);

        /// <summary>
        /// 查找单个数据
        /// </summary>
        /// <param name="expression">条件语句</param>
        /// <returns></returns>
        // Task<T> QuerySingleByExpression(Expression<Func<T, bool>> expression);

        /// <summary>
        /// 查找数据数据
        /// </summary>
        /// <param name="expression">条件语句</param>
        /// <returns></returns>
        // Task<List<T>> FindData(Expression<Func<T, bool>> expression);

        /// <summary>
        /// 查找带分页的数据
        /// </summary>
        /// <param name="expression">条件</param>
        /// <param name="IsPage">是否开启分页</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">每页数量</param>
        /// <param name="order">排序条件</param>
        /// <param name="isAsc">正序倒序</param>
        /// <returns></returns>
        // Task<IQueryable<T>> QueryCondition(Expression<Func<T, bool>> expression, bool IsPage, int PageIndex = 0, int PageSize = 20, Expression<Func<T, object>> order = null, bool isAsc = true);

        #endregion
    }
}
